package com.sskj.hhrt.transaction;

import com.sskj.hhrt.BasePresenter;
import com.sskj.hhrt.api.ApiObserver;
import com.sskj.base.utils.RxUtils;
import com.sskj.hhrt.api.Api;
import com.sskj.hhrt.transaction.data.OrderBean;


/**
 * @author Hey
 * Create at  2019/03/20
 */
class GuaDanPresenter extends BasePresenter<GuaDanFragment> {

    public void getGuaDanList(String account) {
        Api.getInstance().getGuaDanList("dealInfo", account, "2")
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<OrderBean>(this, true) {
                    @Override
                    public void onSuccess(OrderBean data) {
                        mView.setData(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        mView.setData(null);
                    }
                });
    }

    public void cancelOrder(String account, String id) {
        Api.getInstance().cancelOrder("cancelBill", account, id)
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<String>(this,true) {
                    @Override
                    public void onSuccess(String data) {
                        mView.cancelOrderSuccess();
                    }
                });

    }
}
